home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / PredatorPrey / calc_activate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  5.0 KB  |  176 lines  |  [TEXT/KAHL]

  1.  
  2.             /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
  3.             /*                                                               */
  4.             /*                    Prototype HP15C Calculator                */
  5.             /*                    James C. Ullrey                            */
  6.             /*                    INRESCO                                    */
  7.             /*                    © 1990                                    */
  8.             /*                    Version    13.97a                            */
  9.             /*                                                               */
  10.             /*                    ACTIVATE SEGMENT                           */
  11.             /*                                                               */
  12.             /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
  13.  
  14.  
  15.  
  16.  
  17. /*****************************************************************/
  18. /*  I N C L U D E S
  19. /*****************************************************************/
  20.  
  21. #ifndef __C14__
  22. #ifndef __C14__
  23. #include    "PredatorPrey.h"
  24. #endif
  25. #endif
  26. #include    "windows.h"
  27. #include    "calc_activate.h"
  28. #include    "Globals.h"
  29. #include    "HelpWindowProc.h"
  30. #include    "MainMenu.h"
  31.  
  32. /********************************************************************
  33. /*  G L O B A L   V A R I A B L E   D E C L A R A T I O N S
  34. /********************************************************************/
  35. extern    Rect    gPalette_frame;
  36. extern    Rect    gRotation_frame;
  37. extern    Rect    gStretch_frame;
  38. extern    Rect    gDoManyRotation_box;
  39. extern    Rect    gMovement_frame;
  40. extern    Rect    gPlaneControl_frame;
  41.  
  42. /*****************************************************************/
  43. /*  P R O T O T Y P E S
  44. /*****************************************************************/
  45.  
  46.  
  47. //extern    short    one_of_mine                (WindowPtr wPtr);
  48.  
  49. /*extern    void    draw_palette            (WindowPtr wPtr);*/
  50.  
  51. //extern    void    inval_object            (WindowPtr wPtr, short index);
  52. extern        Boolean    DoActivateDeactivate    (WindowPtr    whichWindow,char    adFlag);
  53.  
  54.  
  55. /*****************************************************************/
  56. /*****************************************************************/
  57. /*
  58. /* R O U T I N E S
  59. /*
  60. /*****************************************************************/
  61. /*****************************************************************/
  62.  
  63.  
  64. void    activate_seg() {}        /*  for reference in "UnloadSeg()" calls    */
  65.  
  66.  
  67.  
  68. /*****************************************************************/
  69. /*  D O   A C T I V A T E    -  activate and deactivate windows
  70. /*****************************************************************/
  71.  
  72. /**
  73.     When the system sends an activate event, this routine hides
  74.     the controls and draws the grow icon in the case of a deactivation,
  75.     and, in the case of an activation, draws the controls.  The message
  76.     field of the event record, a long, is cast to a WindowPtr, which
  77.     identifies the window. The modifiers field is masked to determine
  78.     if it is an activate or deactivate event.
  79. **/
  80.  
  81.  
  82. void do_activate(WindowPtr wPtr,Boolean is_activate)
  83. {
  84.     short            index;
  85.     WObjsHandle        w_objs_hndl;
  86.     ControlHandle    h_ctl_hndl;
  87.     ControlHandle    v_ctl_hndl;
  88.     Rect            bounds;
  89.     long            dummy;
  90.     
  91.     if(one_of_mine(wPtr))
  92.     {
  93.         SetPort(wPtr);
  94.         
  95.         w_objs_hndl = (WObjsHandle)GetWRefCon(wPtr);
  96.         
  97.         if(w_objs_hndl != NIL)
  98.         {
  99.             for(index = 0; index < MAX_OBJECTS; index++)    /*    MAX_OBJECTS happens to be 30 */
  100.                 if((**w_objs_hndl).object[index].selected)
  101.                     inval_object(wPtr, index);
  102.             
  103.             h_ctl_hndl = (**w_objs_hndl).myHCntrlHdl;
  104.             v_ctl_hndl = (**w_objs_hndl).myVCntrlHdl;
  105.             
  106.             if(is_activate)
  107.             {
  108.                 if(h_ctl_hndl != NIL) ShowControl(h_ctl_hndl);
  109.                 if(v_ctl_hndl != NIL) ShowControl(v_ctl_hndl);
  110.                 DrawControls(wPtr);
  111.             }
  112.             else
  113.             {
  114.                 if(h_ctl_hndl != NIL) HideControl(h_ctl_hndl);
  115.                 if(v_ctl_hndl != NIL) HideControl(v_ctl_hndl);
  116.             }
  117.             
  118.             HLock((Handle)h_ctl_hndl);                    /* this line of code authored    */
  119.                                                 /* by J. C. Ullrey to cure        */
  120.                                                 /* a serious bug                */
  121.             bounds = (**h_ctl_hndl).contrlRect;
  122.             ValidRect(&bounds);
  123.             HUnlock((Handle)h_ctl_hndl);                /* this line of code authored    */
  124.                                                 /* by J. C. Ullrey to cure        */
  125.                                                 /* a serious bug                */
  126.             
  127.             HLock((Handle)v_ctl_hndl);                    /* this line of code authored    */
  128.                                                 /* by J. C. Ullrey to cure        */
  129.                                                 /* a serious bug                */
  130.             bounds = (**v_ctl_hndl).contrlRect;
  131.             ValidRect(&bounds);
  132.             HUnlock((Handle)v_ctl_hndl);                /* this line of code authored    */
  133.                                                 /* by J. C. Ullrey to cure        */
  134.                                                 /* a serious bug                */
  135.         
  136.  
  137.         }
  138.         if(!(**w_objs_hndl).isPrey)
  139.         {
  140.             InvalRect(&gPalette_frame);        /* I-291    */
  141.     
  142.                                     /* draw_palette(wPtr); <- code replaced    */
  143.                                     /* by InvalRect()                        */
  144.                                     
  145.                                     /* If the window's update rgn is empty  */
  146.                                     /* this action triggers an update event */
  147.                                     /* so that the palette is redrawn.      */
  148.                                     /* If the window's update rgn is not     */
  149.                                     /* empty, the palette area is simply    */
  150.                                     /* added to the update region, and is    */
  151.                                     /* redrawn. The palette is now redrawn     */
  152.                                     /* by the update routine, not by the    */
  153.                                     /* activate routine.  This eliminates     */
  154.                                     /* the double drawing of the palette    */
  155.                                     /* when the windows are brought forward.*/
  156.         }
  157.     
  158.         DrawGrowIcon(wPtr);
  159.     }
  160.  
  161.     else if( wPtr == gRotateBox )
  162.     {
  163.         InvalRect(&gRotation_frame);
  164.         InvalRect(&gDoManyRotation_box);
  165.         InvalRect(&gMovement_frame);
  166.         InvalRect(&gPlaneControl_frame);
  167.     }
  168.     else if( wPtr == gStretchBox )
  169.     {
  170.         InvalRect(&gStretch_frame);
  171.     }
  172.     /*break;*/    /* located in EventLoop.c    */
  173.     return;
  174.  
  175. } /* end of do_activate */
  176.